﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace EvoGame.World
{
    class Map
    {
        public List<Tile> map = new List<Tile>();
    }

    class LayeredTileMap
    {
        public List<Map> layers = new List<Map>();

        public void addMap(Map map)
        {
            layers.Add(map);
        }

        public void remMap(Map map)
        {
            foreach (Map map1 in layers)
                if (map1 == map) layers.Remove(map);
        }

        public void addTileToMap(Map map, Tile tile)
        {
            map.map.Add(tile);
        }

        public void remTileFromMap(Map map, Tile tile)
        {
            foreach (Tile t in map.map)
            {
                if (t == tile) map.map.Remove(tile);
                break;
            }
        }

        public Map getMap(int id)
        {
            return layers[id - 1];
        }

        public Tile getTile(Map map, int x, int y)
        {
            foreach (Tile tile in map.map)
            {
                if (tile.pos.X == x && tile.pos.Y == y)
                    return tile;
            }
            return null;
        }

        public bool isTileSolid(Map map, int x, int y)
        {
            foreach (Tile tile in map.map)
            {
                if (tile.pos.X == x && tile.pos.Y == y)
                    return tile.IsSolid;
            }
            return false;
        }

        public bool isTileOpaque(Map map, Tile tile)
        {
            foreach (Tile t in map.map)
            {
                if (t == tile)
                    return t.IsSolid;
            }
            return false;
        }
    }
}
